using System;
using System.Collections.Generic;
using System.Text;
using ENTITIES;
using DAL;
using Utility;

namespace BUS
{
  public  class HinhThucThanhToanBUS
    {
        public static void Insert(TBHinhThucThanhToan httt)
        {
            HinhThucThanhToanDAL htttDAL = new HinhThucThanhToanDAL();
            htttDAL.Insert(httt);
        }
        public static void Update(TBHinhThucThanhToan httt)
        {
            HinhThucThanhToanDAL htttDAL = new HinhThucThanhToanDAL();
            htttDAL.Update(httt);
        }
        public static void Delete(int iD)
        {
            HinhThucThanhToanDAL htttDAL = new HinhThucThanhToanDAL();
            htttDAL.Delete(iD);
        }
        public static tbHinhThucThanhToanCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            HinhThucThanhToanDAL htttDAL = new HinhThucThanhToanDAL();
            return htttDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbHinhThucThanhToanCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhThucThanhToanDAL htttDAL = new HinhThucThanhToanDAL();
            return htttDAL.Get(cri.Criter, 0, 0, tbHinhThucThanhToanColumns.MaThanhToan.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static TBHinhThucThanhToan GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbHinhThucThanhToanColumns.MaThanhToan.ToString(), Condition.EQUAL, iD);
            HinhThucThanhToanDAL htttDAL = new HinhThucThanhToanDAL();
            tbHinhThucThanhToanCollection hinhthucthanhtoancollection = htttDAL.Get(cri.Criter,
                  0, 0, tbHinhThucThanhToanColumns.MaThanhToan.ToString(), OrderDirection.ASC.ToString(), out total);
            if (hinhthucthanhtoancollection.Count > 0)
                return hinhthucthanhtoancollection[0];
            return null;
        }
        public static tbHinhThucThanhToanCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhThucThanhToanDAL htttDAL = new HinhThucThanhToanDAL();
            return htttDAL.Get(cri.Criter, 1, number,
             tbHinhThucThanhToanColumns.MaThanhToan.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbHinhThucThanhToanCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            HinhThucThanhToanDAL htttDAL = new HinhThucThanhToanDAL();
            return htttDAL.Get(cri.Criter, 1, number,
               tbHinhThucThanhToanColumns.MaThanhToan.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
